package com.woniuxy.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 马宇航
 * @Description: 发布订阅中的广播模式
 * @DateTime: 22/10/20/0020 10:33
 * @Component: 成都蜗牛学苑
 **/
@Configuration
public class FanoutConfig {
    @Bean
    public Queue fanoutQueue1(){
        return new Queue("myFanoutQueue1");
    }
    @Bean
    public Queue fanoutQueue2(){
        return new Queue("myFanoutQueue2");
    }
    /**
     * 定义广播模式交换机
     * ChangeLog : 1. 创建 (22/10/20/0020 10:35 [马宇航]);
     *
     * @return org.springframework.amqp.core.FanoutExchange
    */
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanoutExchange");
    }
    @Bean
    public Binding bindingOne(){
        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());
    }
    @Bean
    public Binding bindingTwo(){
        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());
    }
}
